package com.yhd.controller;

import com.yhd.entity.dto.CourseBookedDto;
import com.yhd.entity.dto.CourseDto;
import com.yhd.entity.dto.SystemDictionaryDto;
import com.yhd.entity.query.CourseBookedVO;
import com.yhd.entity.result.ResultVo;
import com.yhd.model.ResultPage;
import com.yhd.service.CourseService;
import com.yhd.service.CycleImgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@Api(value = "小程序师资相关")
@Slf4j
@RequestMapping(value = "/app/team")
@CrossOrigin
public class AppTeamController extends WebBaseController {

    @Autowired
    private CycleImgService cycleImgService;
    @Autowired
    private CourseService courseService;
    
    @ApiOperation(value = "师资列表", httpMethod = "GET",  notes = "")
    @ApiImplicitParams({@ApiImplicitParam(name = "name", value = "师资名称", required = false, paramType = "字符串"),
            @ApiImplicitParam(name = "classifyId", value = "分类id", required = false, paramType = "int"),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, paramType = "int"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示数量", required = true, paramType = "int")})
    @GetMapping("/list")
    @ResponseBody
    public ResultVo<ResultPage<List<CourseDto>>> courseList(String name,String classifyId, Integer pageSize, Integer pageNum) {
        ResultPage<List<CourseDto>> result = courseService.getTeamList(name, classifyId, pageSize, pageNum);
        return ResultVo.success(result);
    }

    @ApiOperation(value = "师资分类列表", httpMethod = "GET",  notes = "")
    @GetMapping("/classList")
    @ResponseBody
    public ResultVo<List<SystemDictionaryDto>> classList() {
        List<SystemDictionaryDto> result = courseService.getTeamListClassList();
        return ResultVo.success(result);
    }
    
    
    @ApiOperation(value = "师资详情", httpMethod = "GET",notes = "")
	@ApiImplicitParams({@ApiImplicitParam(name = "teamId", value = "师资id", required = true, paramType = "int")})
    @GetMapping("/detail")
    @ResponseBody
    public ResultVo<CourseDto> teamDetail(@RequestParam Integer teamId) {
        CourseDto result = courseService.teamDetail(teamId, getUserInfo(request));
        return ResultVo.success(result);
    }

}
